<?php
	session_start();
	
//	print_r($_POST);
	require_once('../../lib/'.'BaseDir.inc.htm');
	require_once (EIU_LIB.'View.class.htm');
	require_once('../../lib/'.'DBCommon.class.htm');
	require_once (EIU_CLASS.'BaseClass.htm');
	
	if(isset($_POST['page']) && !empty($_POST['page']))
	{
		$startLimit = ($_POST['page']-1)*10;
		$endLimit = 10;
	}
	else
	{
		$startLimit = 0;
		$endLimit = 10;
	}
	
	$condition = "";
	
	//echo $condition;
	$oDB = new DBCommon();
	$conn =  $oDB->stl_openConn();
	
	$count = "
		SELECT COUNT(`ID`)as count 
		FROM `io_tbl` 
		WHERE `isDeleted`=0
		ORDER BY `DeliveryReceiptDate` DESC
	";
	//print($count);exit();
	$rs_count = $oDB->stl_db_select($count, $conn);
	
	//print_r($rs_count);
	if(!empty($rs_count[0]->count)){
		$data1["Count"] = (int)$rs_count[0]->count;
	}		
	
	$q_select = "
		SELECT `ID`,`CostCode`,`DeliveryReceiptDate`,`ReceiptPerson`,`DeliveryPerson`,`Note`,`LastUpdate`,`ModifiedBy`,`PayCash` 
		FROM `io_tbl` 
		WHERE `isDeleted` = 0
		LIMIT ".$startLimit.",".$endLimit.";
	";
	
	//print_r($q_select);
	$rs_select_room=$oDB->stl_db_select($q_select, $conn);
	
	
	if(is_array($rs_select_room))
	{
		$i=0;
		foreach($rs_select_room as $key=>$value)
		{
			$data1['Result'][$i]['ioID']		=	$rs_select_room[$key]->ID;
			//$data1['Result'][$i]['Type']		=	$rs_select_room[$key]->Type;
			$data1['Result'][$i]['CostCode']		=	$rs_select_room[$key]->CostCode;
			$data1['Result'][$i]['DeliveryReceiptDate']		=	changeDateFormat($rs_select_room[$key]->DeliveryReceiptDate,"");
			$data1['Result'][$i]['ReceiptPerson']	=	$rs_select_room[$key]->ReceiptPerson;
			$data1['Result'][$i]['DeliveryPerson']	=	$rs_select_room[$key]->DeliveryPerson;
			//$data1['Result'][$i]['RoomID_Out']	=	$rs_select_room[$key]->RoomID_Out;	
			//$data1['Result'][$i]['BlockCodeOut']		=	$rs_select_room[$key]->BlockCodeOut;
			//$data1['Result'][$i]['RoomCodeOut']		=	$rs_select_room[$key]->RoomCodeOut;
			//$data1['Result'][$i]['BlockCodeIn']		=	$rs_select_room[$key]->BlockCodeIn;
			//$data1['Result'][$i]['RoomCodeIn']		=	$rs_select_room[$key]->RoomCodeIn;
			//$data1['Result'][$i]['RoomID_Input']	=	$rs_select_room[$key]->RoomID_Input;
			$data1['Result'][$i]['Note']		=	$rs_select_room[$key]->Note;
			$data1['Result'][$i]['PayCash']		=	$rs_select_room[$key]->PayCash;
			$i++;
		}
		echo json_encode($data1);
	}else{
		echo 'NG';
	}
	
	$oDB->stl_closeConn($conn);
	
?>
